package com.ziyia.a312;

import androidx.appcompat.app.AppCompatActivity;

import android.os.Bundle;
import android.widget.LinearLayout;
import android.widget.TextView;
import android.widget.Toast;

public class MainActivity extends AppCompatActivity {

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);

        LinearLayout linearLayout = new LinearLayout(this);
        linearLayout.setOrientation(LinearLayout.VERTICAL);

        TextView textView = new TextView(this);
        textView.setText("年少有为");

        linearLayout.addView(textView);

        textView.setOnClickListener(v -> {
            Toast.makeText(this, textView.getText(), Toast.LENGTH_SHORT).show();
        });


        setContentView(linearLayout);
    }
}